package com.yaorange.web.controller.nongjt;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yaorange.common.annotation.Log;
import com.yaorange.common.core.controller.BaseController;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.enums.BusinessType;
import com.yaorange.nongjt.domain.NjtInspectionRecords;
import com.yaorange.nongjt.service.INjtInspectionRecordsService;
import com.yaorange.common.utils.poi.ExcelUtil;
import com.yaorange.common.core.page.TableDataInfo;

/**
 * 农产品检查记录Controller
 * 
 * @author hzliu
 * @date 2025-09-28
 */
@RestController
@RequestMapping("/nongjt/checkRecords")
public class NjtInspectionRecordsController extends BaseController
{
    @Autowired
    private INjtInspectionRecordsService njtInspectionRecordsService;

    /**
     * 查询农产品检查记录列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:checkRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtInspectionRecords njtInspectionRecords)
    {
        startPage();
        List<NjtInspectionRecords> list = njtInspectionRecordsService.selectNjtInspectionRecordsList(njtInspectionRecords);
        return getDataTable(list);
    }

    /**
     * 导出农产品检查记录列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:checkRecords:export')")
    @Log(title = "农产品检查记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtInspectionRecords njtInspectionRecords)
    {
        List<NjtInspectionRecords> list = njtInspectionRecordsService.selectNjtInspectionRecordsList(njtInspectionRecords);
        ExcelUtil<NjtInspectionRecords> util = new ExcelUtil<NjtInspectionRecords>(NjtInspectionRecords.class);
        util.exportExcel(response, list, "农产品检查记录数据");
    }

    /**
     * 获取农产品检查记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:checkRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(njtInspectionRecordsService.selectNjtInspectionRecordsById(id));
    }

    /**
     * 新增农产品检查记录
     */
    @PreAuthorize("@ss.hasPermi('nongjt:checkRecords:add')")
    @Log(title = "农产品检查记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NjtInspectionRecords njtInspectionRecords)
    {
        return toAjax(njtInspectionRecordsService.insertNjtInspectionRecords(njtInspectionRecords));
    }

    /**
     * 修改农产品检查记录
     */
    @PreAuthorize("@ss.hasPermi('nongjt:checkRecords:edit')")
    @Log(title = "农产品检查记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NjtInspectionRecords njtInspectionRecords)
    {
        return toAjax(njtInspectionRecordsService.updateNjtInspectionRecords(njtInspectionRecords));
    }

    /**
     * 删除农产品检查记录
     */
    @PreAuthorize("@ss.hasPermi('nongjt:checkRecords:remove')")
    @Log(title = "农产品检查记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(njtInspectionRecordsService.deleteNjtInspectionRecordsByIds(ids));
    }
}
